var mRequest = require('./settingService.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    items:[
      {
        title:"收货地址",
        action:"addressAction",
        value:"",
      },
      {
        title: "绑定手机",
        action: "bindPhone",
        value: "未绑定",
      }, 
      // {
      //   title: "修改密码",
      //   action: "modifyPassword",
      //   value: "",
      // }, 
      {
        title: "客服电话",
        action: "serveNO",
        value: "4009005670",
      },
    ],
    isBindPhone: false  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onShow: function (options) {
      this.initRequeat()
  },

  initRequeat: function () {
    let self = this
    mRequest.getSettings(
      function(data){
        if(data){
          self.data.items[1].value = data.mobile ? data.mobile: '未绑定'
          self.data.items[2].value = data.telphone
          self.setData({
            items: self.data.items,
            isBindPhone: data.mobile ? true : false
          })
        }
      },
      function(error){

      })
  },

  addressAction: function(){
    wx.navigateTo({
      url: '../../addProduct/myAddress/myAddres',
    })
  },
  bindPhone: function(){
    if (this.data.isBindPhone == true){
      wx.showToast({
        title: '已完成绑定',
        icon: "none"
      })
      return
    }
    wx.navigateTo({
      url: './bindingPhone/bindingPhone',
    })
  },
  modifyPassword: function(){
    wx.navigateTo({
      url: './modifiPassword/modifiPassword',
    })
  },

})